package com.atguigu.daijia.payment.config;

import com.binarywang.spring.starter.wxjava.pay.properties.WxPayProperties;
import com.github.binarywang.wxpay.config.WxPayConfig;
import com.github.binarywang.wxpay.service.WxPayService;
import com.github.binarywang.wxpay.service.impl.WxPayServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class WxPayConfiguration {

    @Autowired
    private WxPayV3Properties payProperties;

    @Bean
    public WxPayService wxPayService() {
            com.github.binarywang.wxpay.service.impl.WxPayServiceImpl wxPayService = new WxPayServiceImpl();

        WxPayConfig payConfig = new WxPayConfig();

        payConfig.setAppId(payProperties.getAppId());

        payConfig.setMchId(payProperties.getMchId());

        payConfig.setMchKey(payProperties.getMchKey());

        payConfig.setNotifyUrl(payProperties.getNotifyUrl());

        wxPayService.setConfig(payConfig);

        return wxPayService;
    }

}


